﻿//vs
//#version 330 core 

layout(location = 0) in vec2 inPosition;

void main() {
    //get the clip space position from the object space position
    gl_Position = vec4(inPosition.xy * 2 - 1.0, 0, 1);
}

//fs
//#version 330 core

layout(location = 0) out vec4 outColor;

//uniforms
uniform sampler2DRect colorTexture;	//color texture from previous pass
uniform vec4 backgroundColor;		//background color
uniform bool useBackground = true;

void main() {
    //get the color from the color buffer
    vec4 color = texture(colorTexture, gl_FragCoord.xy);
    //combine the color read from the color texture with the background color
    //by multiplying the color alpha with the background color and adding the 
    //product to the given color uniform
    if (useBackground) {
        outColor = color + backgroundColor * color.a;
    }
    else {
        outColor = color;
    }
}
